$(document).ready(function () {
    //加载标题栏的下拉列表
    $.ajax({
        type: "get",
        url: "/InitServlet",
        data: "action=getClass",
        dataType: "json",
        success: function (data) {
            // $("#classManager").html("");
            for (var i in data) {
                $("#classManager").prepend("<li>\n" + "<a href=\"/InitServlet?action=initClass&class_id=" + data[i] + "\">" + data[i] + "</a></li>");
            }
        },
    });

    //选择搜索引擎
    $("#searchText").next().children().children().click(function () {
        $("#searchText").html($(this).attr('alt')+"<strong class='caret'>");
    });

});

function goSearch() {
    var searchEngine=$("#searchText").html().substr(0,2);
    var searchContext=$("#searchContext").val();
    if(searchEngine=="搜狗"){
        open("https://www.sogou.com/web?query="+searchContext)
    }else if(searchEngine=="百度"){
        open("https://www.baidu.com/s?wd="+searchContext);
    }else if(searchEngine=="谷歌"){
        open("https://www.google.com/search?h/=zh-CH&q="+searchContext);
    }
}